<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="title"
  [loading]="isLoading()"
></ix-modal-header>

<mat-card>
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <ix-fieldset [title]="'Set Quotas' | translate">
        <ix-input
          formControlName="data_quota"
          [label]="dataQuotaLabel | translate"
          [tooltip]="dataQuotaTooltip | translate"
          [format]="formatter.memorySizeFormatting"
          [parse]="formatter.memorySizeParsing"
        ></ix-input>

        <ix-input
          formControlName="obj_quota"
          type="number"
          [label]="objectQuotaLabel | translate"
          [tooltip]="objectQuotaTooltip | translate"
        ></ix-input>
      </ix-fieldset>

      @if (quotaType === DatasetQuotaType.User) {
        <ix-fieldset
          [title]="'Apply Quotas to Selected Users' | translate"
        >
          <ix-chips
            formControlName="users"
            [label]="'Apply To Users' | translate"
            [tooltip]="tooltips.users | translate"
            [autocompleteProvider]="usersProvider"
            [allowNewEntries]="false"
          ></ix-chips>
        </ix-fieldset>
      }

      @if (quotaType === DatasetQuotaType.Group) {
        <ix-fieldset
          [title]="'Apply Quotas to Selected Groups' | translate"
        >
          <ix-chips
            formControlName="groups"
            [label]="'Apply To Groups' | translate"
            [tooltip]="tooltips.groups | translate"
            [required]="true"
            [autocompleteProvider]="groupProvider"
          ></ix-chips>
        </ix-fieldset>
      }

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          type="submit"
          mat-button
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isLoading()"
        >
          {{ 'Save' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
